package net.hn.hnms.biz.safety.wind.Dao;

import net.hn.hnms.biz.safety.wind.entity.PositionEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author 智呈物联 nzw
 * @date 2022/12/21
 */
public interface PositionDao extends JpaRepository<PositionEntity,Long> {

    @Query(value = "SELECT\n" +
            "\t* \n" +
            "FROM\n" +
            "\t\"position\" \n" +
            "WHERE\n" +
            "CASE\n" +
            "\t\t\n" +
            "\t\tWHEN ?1!= '' THEN\n" +
            "\tTRIM ( mine_code ) = ?1 ELSE 1 = 1 \n" +
            "END",nativeQuery = true)
    List<PositionEntity> findAllByMineCode(String mineCode);

    @Query(value = "SELECT\n" +
            "\t* \n" +
            "FROM\n" +
            "\t\"position\"\n" +
            "WHERE\n" +
            "\tposition_id = ?",nativeQuery = true)
    PositionEntity getById(Long Long);
}
